<template>
  <!-- 内部机构维护详情-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
    v-if="openState"
  >
    <el-form ref="form" :model="form" :disabled="true" :rules="detailRules" label-width="110px">
      <!--内部机构列表-->
      <!--关联内部机构信息-->
      <el-card class="form-card orgInfo-card">
        <div slot="header" class="label-header-msg">
          <span></span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="内部机构号" prop="brno">
              <el-input
                v-model="form.brno"
                placeholder="内部机构号"
                :disabled = "true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="内部机构名称" prop="brname">
              <el-input
                v-model="form.brname"
                placeholder="内部机构名称"
                :disabled = "true"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <!--渠道信息-->
      <el-card class="form-card chnlInfo-card">
        <div slot="header" class="label-header-msg">
          <span>基本信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="渠道" prop="sysType">
              <el-select v-model="form.sysType" placeholder="渠道" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.ORGAN_SYSTYPE_BRANCH"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="渠道系统状态" prop="curSysStatus">
              <el-select v-model="form.curSysStatus" placeholder="渠道系统状态" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.SYSTEMSTATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="渠道系统日期" prop="curSysDate">
              <el-date-picker v-model="form.curSysDate" style="width: 100%" type="date" value-format="yyyyMMdd" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入点" prop="accessPoint">
              <el-select v-model="form.accessPoint" placeholder="接入点" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.ACCESS_POINT"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--关联行信息-->
      <el-card class="form-card bankInfo-card">
        <div slot="header" class="label-header-msg">
          <span>参与行信息</span>
        </div>

        <el-row>
          <el-col :span="12">
            <el-form-item label="参与行行号" prop="bankCode">
              <el-input v-model="form.bankCode" placeholder="参与行行号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="参与行行名" prop="orgFullname">
              <el-input v-model="form.orgFullname" placeholder="参与行行名" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="参与机构类别" prop="bankType">
              <el-select v-model="form.bankType" placeholder="参与机构类别" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.PT_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="清算行行号" prop="drctBankCode">
              <el-input v-model="form.drctBankCode" placeholder="清算行行号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="清算行行名" prop="drctBankName">
              <el-input v-model="form.drctBankName" placeholder="清算行行名" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="所在城市代码" prop="lglCtcode">
              <el-input v-model="form.lglCtcode" placeholder="所在城市代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属CPCC" prop="lglCcpc">
              <el-input v-model="form.lglCcpc" placeholder="所属CPCC" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--审核信息-->
      <el-card class="form-card bankInfo-card">
        <div slot="header" class="label-header-msg">
          <span>处理信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="form.id" placeholder="交易流水号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="维护类型" prop="optType">
              <el-select v-model="form.optType" placeholder="维护类型" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.BRANCH_OP_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核状态" prop="optStatus">
              <el-select v-model="form.optStatus" placeholder="审核状态" style="width: 100%">
                <el-option
                  v-for="dict in dictMap.ORGAN_OP_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="录入操作员" prop="creater">
              <el-input v-model="form.creater" placeholder="录入操作员" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入时间" prop="createdDate">
              <el-date-picker
                style="width: 100%"
                v-model="form.createdDate"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve">审 核</el-button>
      <el-button type="primary" @click="reject">拒 绝</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { apiUrlConfigCheckBrnoDetail, brnoApproveDetail, brnoApprove, brnoReject } from "@/api/cnaps/bizMng/brnoBind.js";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "brnoApproveDetail",
  mixins: [listPageMixin],
  components: {},
  props: {},
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      reqConfig: apiUrlConfigCheckBrnoDetail,
      // 查询参数
      queryParams: {
        id: "",
      },
      // 字段可编辑控制

      //数据字典
      searchFormDictList: ["ORGAN_SYSTYPE_BRANCH", "SYSTEMSTATUS", "ACCESS_POINT", "PT_TYPE", "BRANCH_OP_TYPE", "ORGAN_OP_STATUS"],
      // 表单参数
      form: {},
      // 表单校验
      detailRules: {
        sysType: [{ required: true, disabled: true, message: "请选择渠道", trigger: "blur" }],
        curSysStatus: [{ required: true, disabled: true, message: "请选择渠道系统状态", trigger: "blur" }],
        curSysDate: [{ required: true, disabled: true, message: "请选择渠道系统日期", trigger: "blur" }],
        accessPoint: [{ required: true, disabled: true, message: "请输入接入点", trigger: "blur" }],

        brno: [{ required: true, disabled: true, message: "请输入内部机构", trigger: "blur" }],
        brname: [{ required: true, disabled: true, message: "请输入内部机构名称", trigger: "blur" }],
        bankCode: [{ required: true, disabled: true, message: "请输入参与行行号", trigger: "blur" }],
        orgFullname: [{ required: true, disabled: true, message: "请输入参与行行名", trigger: "blur" }],
        bankType: [{ required: true, disabled: true, message: "请选择参与机构类别", trigger: "blur" }],
        drctBankCode: [{ required: true, disabled: true, message: "请输入清算行行号", trigger: "blur" }],
        drctBankName: [{ required: true, disabled: true, message: "请输入清算行行名", trigger: "blur" }],
        lglCtcode: [{ required: true, disabled: true, message: "请输入所在城市代码", trigger: "blur" }],
        lglCcpc: [{ required: true, disabled: true, message: "请输入所属CPCC", trigger: "blur" }],
      },
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", width: "460px" },
        { label: `渠道`, prop: "sysType", width: "460px", dictCode: "ORGAN_SYSTYPE_BRANCH" },
      ],
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("form");
      this.$set(this, "form", {});
    },
    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", true);
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {});
    },
    show(row) {
      this.form = row;
      this.title = "内部机构维护审核明细";
      this.openState = true;
      this.queryParams.id = row.id;
      this.brnoApproveDetail(row);
    },

    brnoApproveDetail: function (row) {
      brnoApproveDetail(row).then((response) => {
        this.showData(response);
      });
    },

    showData: function (response) {
      this.form = response.result.data;
      this.$set(this.form,"brno",response.result.branches[0].brno)
      this.$set(this.form,"brname",response.result.branches[0].brname)
    },

    /** TODO审批按钮 */
    approve() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          brnoApprove(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批通过");
              this.cancel();
            }
          });
        }
      });
    },

    /** TODO拒绝按钮 */
    reject() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          brnoReject(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批已拒绝");
              this.cancel();
            }
          });
        }
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
